<!--
 * @Author: xinqiao lxq1990.0716@qq.com
 * @Date: 2023-11-29 10:57:44
 * @LastEditors: xinqiao lxq1990.0716@qq.com
 * @LastEditTime: 2024-01-10 10:39:34
 * @FilePath: \partal\src\views\Home.vue
 * @Description: 首页
-->
<script lang="ts" setup>
  import { useRouter } from 'vue-router'
  import { homePng } from '@/enum/imageEnum'
  import { PAGE_DEVELOP_GUIDE, PAGE_DESIGN_INTRODUCE, PAGE_PROJECT_PROJECT } from '@/enum/pageEnum'
  import { PLANTTYPE_ENUM } from '@/enum/globalEnum'
  import { usePlant } from '@/stores/plant'

  const router = useRouter()
  const plant = usePlant()

  /**
   * 路由跳转：设计指南-简介
   */
  const goDesignIntroduce = () => router.push({ path: PAGE_DESIGN_INTRODUCE })

  /**
   * 路由跳转：开发指南-概述
   * @param plantType 平台类型
   */
  const goDevelopGuide = (plantType: PLANTTYPE_ENUM) => {
    plant.setPlantType(plantType)
    router.push({ path: PAGE_DEVELOP_GUIDE })
  }

  /**
   * 路由跳转：项目案例
   */
  const goProject = () => router.push({ path: PAGE_PROJECT_PROJECT })
</script>

<template>
  <div class="main">
    <img class="main-bg" :src="homePng.mainBg" />
    <div class="main-content">
      <img class="main-content-logo" :src="homePng.mainLogo" />
      <div class="main-content-button">
        <button @click="goDevelopGuide(PLANTTYPE_ENUM.PC)">PC端</button>
        <button @click="goDevelopGuide(PLANTTYPE_ENUM.APP)">移动端</button>
        <button @click="goDevelopGuide(PLANTTYPE_ENUM.XCX)">小程序端</button>
        <button @click="goDevelopGuide(PLANTTYPE_ENUM.H5)">H5端</button>
      </div>
    </div>
  </div>
  <div class="action">
    <div class="action-item">
      <img class="action-item-logo" :src="homePng.actionDesign" />
      <span class="action-item-title">设计指南</span>
      <span class="action-item-desc">可配置主题色、字体、间距、圆角等通用属性</span>
      <span class="action-item-detail" @click="goDesignIntroduce()">查看详情</span>
    </div>
    <div class="action-item">
      <img class="action-item-logo" :src="homePng.actionComponent" />
      <span class="action-item-title">开发组件</span>
      <span class="action-item-desc">涵盖导航、图表、表单、弹窗等30多种组件--覆盖常见开发场景</span>
      <span class="action-item-detail" @click="goDevelopGuide(plant.plantType)">查看详情</span>
    </div>
    <div class="action-item">
      <img class="action-item-logo" :src="homePng.actionExample" />
      <span class="action-item-title">项目案例</span>
      <span class="action-item-desc">包含组件设计文件和定制化标注插件，可快速产出设计稿</span>
      <span class="action-item-detail" @click="goProject()">查看详情</span>
    </div>
  </div>
</template>

<style type="less" scoped>
  .main {
    position: relative;
    > .main-bg {
      display: block;
      width: 100%;
      height: auto;
    }
    > .main-content {
      position: absolute;
      width: 1200px;
      margin: auto;
      inset: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
      > .main-content-logo {
        width: 330px;
        height: 130px;
      }
      > .main-content-button {
        display: grid;
        grid-template-rows: 44px 44px;
        grid-template-columns: 156px 156px;
        grid-gap: 18px 12px;
        width: 324px;
        height: 106px;
        margin-top: 80px;
        > button {
          cursor: pointer;
          width: 156px;
          height: 44px;
          border: none;
          background: #fafcff;
          border-radius: 4px;
          font-size: 16px;
          color: #4e5969;
          line-height: 24px;
        }
      }
    }
  }
  .action {
    width: 1200px;
    height: 360px;
    margin: auto;
    padding-top: 80px;
    display: flex;
    justify-content: space-between;

    > .action-item {
      position: relative;
      width: 384px;
      height: 140px;
      display: flex;
      flex-direction: column;

      > .action-item-logo {
        position: absolute;
        top: 0;
        left: 0;
        width: 140rpx;
        height: 140px;
      }
      > .action-item-title {
        margin: 16px 0 0 160px;
        font-size: 18px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: bold;
        color: #1d2129;
        line-height: 25px;
      }
      >.action-item-desc {
        margin: 8px 0 0 160px;
        font-size: 14px;
        color: #4e5969;
        line-height: 22px;
      }
      >.action-item-detail {
        margin: 12px 0 0 160px;
        font-size: 14px;
        color: #1677ff;
        line-height: 20px;
        cursor: pointer;
      }
    }
  }
</style>
